package io.renren.modules.sys.service.impl;

import io.renren.modules.sys.entity.HealthheadlineVOEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.HealthheadlineDao;
import io.renren.modules.sys.entity.HealthheadlineEntity;
import io.renren.modules.sys.service.HealthheadlineService;


@Service("healthheadlineService")
public class HealthheadlineServiceImpl extends ServiceImpl<HealthheadlineDao, HealthheadlineEntity> implements HealthheadlineService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        int pageSize = Integer.parseInt(params.get("limit").toString());  //每页记录数
        int currPage = Integer.parseInt(params.get("page").toString());  //当前页数

        String dname = null;
        if( params.get("dname")!=null&&!params.get("dname").equals("")){
            dname = params.get("dname").toString();
        }

        String startime = null;
        if(params.get("startime")!=null && !params.get("startime").equals("")){
            startime = params.get("startime").toString();
        }
        String endtime = null;
        if(params.get("endtime")!=null && !params.get("endtime").equals("")){
            endtime = params.get("endtime").toString();
        }
        int count = baseMapper.queryListcount(dname,startime,endtime);
        List<HealthheadlineVOEntity> list = baseMapper.querylistByParams(dname,startime,endtime,(currPage-1)*pageSize,currPage*pageSize);

        return new PageUtils(list,count,pageSize,currPage);
    }

}
